package com.huiyuan.service.impl;

import com.github.pagehelper.PageHelper;
import com.huiyuan.common.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import com.huiyuan.mapper.BikeMapper;
import com.huiyuan.common.Bike;
import com.huiyuan.service.BikeService;

/**
 * @author huiyuan080
 * @data 2023/5/2
 * @apiNote
 */
@Service
public class BikeServiceImpl implements BikeService {

    @Resource
    private BikeMapper bikeMapper;

    @Override
    public int deleteByPrimaryKey(Integer bikeId) {
        return bikeMapper.deleteByPrimaryKey(bikeId);
    }

    @Override
    public int insert(Bike record) {
        return bikeMapper.insert(record);
    }

    @Override
    public int insertSelective(Bike record) {
        return bikeMapper.insertSelective(record);
    }

    @Override
    public Bike selectByPrimaryKey(Integer bikeId) {
        return bikeMapper.selectByPrimaryKey(bikeId);
    }

    @Override
    public int updateByPrimaryKeySelective(Bike record) {
        return bikeMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Bike record) {
        return bikeMapper.updateByPrimaryKey(record);
    }

    /**
     * 分页展示车辆信息
     *
     * @param page
     * @return
     */
    @Override
    public Page getBicycle(Page page) {
        com.github.pagehelper.Page<Object> pageHelper = PageHelper.startPage(page.getPageNumber(), page.getPageSize());
        this.bikeMapper.getPage();
        page.setList(pageHelper.getResult());
        page.setTotalCount(pageHelper.getTotal());
        return page;
    }

    /**
     * 修改车辆的使用情况
     * @param bicycleId
     * @return
     */
    @Override
    public int addUse(Integer bicycleId) {
        return  bikeMapper.addUse(bicycleId);
    }


    /**
     * 车辆的状态
     * @param bicycleId
     * @return
     */
    @Override
    public Bike isNull(Integer bicycleId) {

        return bikeMapper.isNull(bicycleId);
    }
}
